package com.qhhc.hospital.controller;

import com.qhhc.hospital.entity.AdminUser;
import com.qhhc.hospital.service.IAdminUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class AdminUserController {
    @Autowired
    IAdminUserService adminUserService;

    @RequestMapping("/insertAdminUser")
    public String insertAdminUser(@RequestBody AdminUser adminUser){
        adminUserService.insert(adminUser);
        return "success";
    }

    @RequestMapping("/getAllAdminUsers")
    public List<AdminUser> getAllAdminUsers(){
        List<AdminUser> adminUsers = adminUserService.selectAll();
        return adminUsers;
    }

    @RequestMapping("/getAdminUser/{aId}")
    public AdminUser getAdminUserById(@PathVariable("aId") Integer aId){
        return adminUserService.selectById(aId);
    }

    @RequestMapping("/updateAdminUser")
    public String updateAdminUser(@RequestBody AdminUser adminUser){
        adminUserService.update(adminUser);
        return "success";
    }

    @RequestMapping("/deleteAdminUser/{aId}")
    public String deleteAdminUser(@PathVariable("aId") Integer aId){
        adminUserService.delete(aId);
        return "success";
    }
} 